예제 #1
0
        public async Task <IActionResult> FeatureNotification([FromBody] FeatureNotificationViewModel value)
        {
            if (ModelState.IsValid)
            {
                //
                var userId = Utilities.GetUserId(this.User);

                var ar = new FeatureNotification
                {
                    FeatureNotificationId = Guid.NewGuid(),
                    FeatureId             = value.FeatureId,
                    Emails        = value.Emails,
                    TemplateEmail = value.TemplateEmail,
                    CreatedBy     = userId,
                    CreatedDate   = DateTime.Now,
                    UpdatedBy     = userId,
                    UpdatedDate   = DateTime.Now
                };

                //commit
                var ret = await this._unitOfWork.Features.SaveFeatureNotification(ar);

                //return client side
                return(Ok(ret));
            }

            return(BadRequest(ModelState));
        }
예제 #2
0
파일: Feature.cs 프로젝트: tuynv90/ebrain
        public async Task <bool> SaveFeatureNotification(FeatureNotification feature)
        {
            var branchId  = feature.CreatedBy.Value.GetBranchOfCurrentUser(this.appContext);
            var itemExist = this.appContext.FeatureNotification.FirstOrDefault(p => p.FeatureId == feature.FeatureId && p.BranchId == branchId);

            if (itemExist != null)
            {
                itemExist.UpdatedDate   = DateTime.Now;
                itemExist.Emails        = feature.Emails;
                itemExist.TemplateEmail = feature.TemplateEmail;
                itemExist.BranchId      = branchId;
            }
            else
            {
                this.appContext.FeatureNotification.Add(feature);
            }
            return(this.appContext.SaveChanges() > 0);
        }