Skip to content

Instantly share code, notes, and snippets.

@resting
Created June 1, 2020 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resting/a210fd9d5cd927bbd2f826d7364aefc7 to your computer and use it in GitHub Desktop.
Save resting/a210fd9d5cd927bbd2f826d7364aefc7 to your computer and use it in GitHub Desktop.
using (var transaction = UnitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
{
var _itemSendSMS = _feoSendSMSRepository.GetAll().Where(x => x.Staff_ID == item.StaffId && x.CreationTime>= DateTime.UtcNow.AddMonths(-3)).FirstOrDefault();
if (_itemSendSMS == null)
{
var _feoSendSMS = new FeoSendSMS()
{
MemberID = item.MemberId,
Staff_ID = item.StaffId,
MobileNumber = item.MobileNumber,
ContentInput = item.ContentInput,
DefaultSMS = item.DefaultSMS,
TemplateSMS = item.TemplateSMS,
Header = item.Header,
Footer=item.Footer,
ContentFull = item.ContentFull.Replace("#",""),
Status = status == true ? 1 : 0,
DateSend = Clock.Now,
Forward=string.IsNullOrEmpty(item.StaffIdForward)?false: true,
CountSend = 1
};
if (claimsId != 0)
_feoSendSMS.CreatorUserId = claimsId;
if (claimsEmail != "")
_feoSendSMS.CreationByEmail = claimsEmail;
_feoSendSMSRepository.Insert(_feoSendSMS);
CurrentUnitOfWork.SaveChanges();
}
else
{
_itemSendSMS.CountSend += 1;
_feoSendSMSRepository.Update(_itemSendSMS);
CurrentUnitOfWork.SaveChanges();
var _feoSendSMSLog = new FeoSendSMSLog()
{
MemberID = item.MemberId,
Staff_ID = item.StaffId,
MobileNumber = item.MobileNumber,
ContentInput = item.ContentInput,
DefaultSMS = item.DefaultSMS,
TemplateSMS = item.TemplateSMS,
Header = item.Header,
Footer = item.Footer,
ContentFull = item.ContentFull.Replace("#", ""),
Status = status == true ? 1 : 0,
DateSend = Clock.Now,
CreatorUserId = claimsId,
CreationByEmail = claimsEmail,
Forward = string.IsNullOrEmpty(item.StaffIdForward) ? false : true,
};
_feoSendSMSLogRepository.Insert(_feoSendSMSLog);
CurrentUnitOfWork.SaveChanges();
}
transaction.Complete();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment