Example #1
0
 public ApiActionResult UpdateCommonValues(CommonValueUpdateModel model)
 {
     try
     {
         CommonValues obj = new CommonValues();
         obj = _dbConfigContext.CommonValues.AsNoTracking().FirstOrDefault(x => x.Id == model.Id);
         if (obj != null)
         {
             obj.ValueDouble = model.ValueDouble;
             obj.ValueGroup  = model.ValueGroup;
             obj.ValueInt    = model.ValueInt;
             obj.ValueString = model.ValueString;
             obj.Text        = model.Text;
             obj.OrderBy     = model.OrderBy;
             var resUpdate = _dbConfigContext.CommonValues.Update(obj);
             int flag      = _dbConfigContext.SaveChanges();
             if (flag != 0)
             {
                 return(ApiActionResult.Success());
             }
             return(ApiActionResult.Failed("Updated failed"));
         }
         return(ApiActionResult.Failed("Can not updated because entity doest not existed!!"));
     }
     catch (Exception ex)
     {
         return(ApiActionResult.Failed(ex.Message));
     }
 }
 public ApiActionResult CreateNewList(List <CommonResourcesCreateModel> model)
 {
     try
     {
         if (model.Count > 0)
         {
             for (int i = 0; i < model.Count; i++)
             {
                 CommonResources obj = new CommonResources();
                 obj = _mapper.Map <CommonResources>(model[i]);
                 if (_dbConfigContext.CommonResources.Any(x => x.ResourceKey == obj.ResourceKey && x.LanguageFid == obj.LanguageFid))
                 {
                     CommonResources updated = _dbConfigContext.CommonResources.Where(x => x.ResourceKey == obj.ResourceKey && x.LanguageFid == obj.LanguageFid).FirstOrDefault();
                     updated.ResourceValue  = obj.ResourceValue;
                     updated.TypeOfResource = obj.TypeOfResource;
                     _dbConfigContext.CommonResources.Update(updated);
                     _dbConfigContext.SaveChanges();
                 }
                 else
                 {
                     _dbConfigContext.CommonResources.Add(obj);
                     _dbConfigContext.SaveChanges();
                 }
             }
             return(ApiActionResult.Success());
         }
         return(ApiActionResult.Failed("Created Failed!!"));
     }
     catch (Exception ex)
     {
         return(ApiActionResult.Failed(ex.Message));
     }
 }
Example #3
0
 public ApiActionResult Update(CommonLanguaguesUpdateModel model)
 {
     try
     {
         CommonLanguages obj = new CommonLanguages();
         obj = _dbConfigContext.CommonLanguages.AsNoTracking().FirstOrDefault(x => x.Id == model.Id);
         if (obj != null)
         {
             obj.LanguageCode = model.LanguageCode;
             obj.LanguageName = model.LanguageName;
             obj.Remarks      = model.Remarks;
             obj.ResourceKey  = model.ResourceKey;
             _dbConfigContext.CommonLanguages.Update(obj);
             int flag = _dbConfigContext.SaveChanges();
             if (flag != 0)
             {
                 return(ApiActionResult.Success());
             }
             return(ApiActionResult.Failed("Updated failed"));
         }
         return(ApiActionResult.Failed("Can not updated because entity doest not existed!!"));
     }
     catch (Exception ex)
     {
         return(ApiActionResult.Failed(ex.Message));
     }
 }
 public ApiActionResult Update(CommonResourcesUpdateModel model)
 {
     try
     {
         CommonResources obj = new CommonResources();
         obj = _dbConfigContext.CommonResources.AsNoTracking().FirstOrDefault(x => x.ResourceKey == model.ResourceKey);
         if (obj != null)
         {
             obj.ResourceValue  = model.ResourceValue;
             obj.TypeOfResource = model.TypeOfResource;
             _dbConfigContext.CommonResources.Update(obj);
             var flag = _dbConfigContext.SaveChanges();
             if (flag != 0)
             {
                 return(ApiActionResult.Success());
             }
             return(ApiActionResult.Failed("Updated failed"));
         }
         return(ApiActionResult.Failed("Can not updated because entity doest not existed!!"));
     }
     catch (Exception ex)
     {
         return(ApiActionResult.Failed(ex.Message));
     }
 }
Example #5
0
        public ApiActionResult UpdatePost(PostCreateModel model)
        {
            try
            {
                var obj = _dbCMSContext.Posts.AsNoTracking().FirstOrDefault(x => x.Id == model.Id);
                obj.DefaultTitle       = model.DefaultTitle;
                obj.TimeToRead         = model.TimeToRead;
                obj.IsActivated        = model.IsActivated;
                obj.Deleted            = model.Deleted;
                obj.CreatedBy          = obj.CreatedBy;
                obj.PostCategoryFid    = model.PostCategoryFid;
                obj.PostCategoryResKey = model.PostCategoryResKey;
                _dbCMSContext.Update(obj);
                _dbCMSContext.SaveChanges();

                var objDetail = _dbCMSContext.PostDetails.AsNoTracking().FirstOrDefault(x => x.Id == model.postDetail.Id);
                objDetail.KeyWord          = model.postDetail.KeyWord;
                objDetail.IsActivated      = model.postDetail.IsActivated;
                objDetail.LanguageFid      = model.postDetail.LanguageFid;
                objDetail.MetaDescription  = model.postDetail.MetaDescription;
                objDetail.Body             = model.postDetail.Body;
                objDetail.Deleted          = model.postDetail.Deleted;
                objDetail.Title            = model.postDetail.Title;
                objDetail.LastModifiedDate = DateTime.Now;
                objDetail.FileStreamFid    = model.postDetail.FileStreamFid;
                objDetail.FileTypeFid      = model.postDetail.FileTypeFid;

                var objFileStream = _dbCMSContext.PostFileStreams.AsNoTracking().Where(x => x.PostFid == model.Id).ToList();
                for (int i = 0; i < objFileStream.Count; i++)
                {
                    if (objFileStream[i].Id == model.postFileStream[i].Id)
                    {
                        objFileStream[i].ActivatedDate      = model.postFileStream[i].ActivatedDate;
                        objFileStream[i].FileCategoryFid    = model.postFileStream[i].FileCategoryFid;
                        objFileStream[i].FileCategoryResKey = model.postFileStream[i].FileCategoryResKey;
                        objFileStream[i].FileStreamFid      = model.postFileStream[i].FileStreamFid;
                        objFileStream[i].FileTypeFid        = model.postFileStream[i].FileTypeFid;
                        objFileStream[i].FileTypeResKey     = model.postFileStream[i].FileTypeResKey;
                        objFileStream[i].LastModifiedDate   = DateTime.Now;
                    }
                }
                return(ApiActionResult.Success());
            }
            catch (Exception ex)
            {
                return(ApiActionResult.Failed(ex.Message));
            }
        }
Example #6
0
        public ApiActionResult Create(CommonLanguaguesCreateModel model)
        {
            try
            {
                CommonLanguages obj = new CommonLanguages();
                obj          = _mapper.Map <CommonLanguages>(model);
                obj.UniqueId = UniqueIDHelper.GenerateRandomString(12);

                _dbConfigContext.CommonLanguages.Add(obj);
                _dbConfigContext.SaveChanges();
                return(ApiActionResult.Success());
            }
            catch (Exception ex)
            {
                return(ApiActionResult.Failed(ex.Message));
            }
        }
Example #7
0
        public ApiActionResult CreateNewSubscriber(SubscriberCreateModel model)
        {
            try
            {
                Subscribers obj = new Subscribers();
                obj = _mapper.Map <Subscribers>(model);
                var res = _dbCMSContext.Subscribers.Add(obj);
                _dbCMSContext.SaveChanges();
                return(ApiActionResult.Success());
            }
            catch (Exception ex)
            {
                return(ApiActionResult.Failed(ex.Message));

                throw ex;
            }
        }
Example #8
0
        public ApiActionResult CreateNewPost(PostCreateModel model)
        {
            try
            {
                model.UniqueId = UniqueIDHelper.GenerateRandomString(12);
                Posts obj = new Posts();
                obj = _mapper.Map <Posts>(model);
                obj.LastModifiedDate = model.LastModifiedDate;
                obj.Deleted          = false;
                var res = _dbCMSContext.Posts.Add(obj);
                _dbCMSContext.SaveChanges();
                if (res.Entity.Id > 0)
                {
                    model.postFileStream.ForEach(x => x.PostFid = res.Entity.Id);
                    var objFileStream = model.postFileStream.Select(k => new PostFileStreams
                    {
                        FileCategoryFid    = k.FileCategoryFid,
                        FileCategoryResKey = k.FileCategoryResKey,
                        PostFid            = res.Entity.Id,
                        FileStreamFid      = k.FileStreamFid,
                        FileTypeFid        = k.FileTypeFid,
                        FileTypeResKey     = k.FileTypeResKey,
                        ActivatedDate      = k.ActivatedDate,
                        LastModifiedDate   = model.LastModifiedDate.Value,
                        LastModifiedBy     = k.LastModifiedBy,
                        Deleted            = false
                    });
                    _dbCMSContext.PostFileStreams.AddRange(objFileStream);
                    _dbCMSContext.SaveChanges();
                    PostDetails objDetail = new PostDetails();
                    objDetail = _mapper.Map <PostDetails>(model.postDetail);
                    objDetail.LastModifiedDate = model.postDetail.LastModifiedDate;
                    objDetail.Deleted          = false;
                    objDetail.PostFid          = res.Entity.Id;
                    var resDetail = _dbCMSContext.PostDetails.Add(objDetail);
                    _dbCMSContext.SaveChanges();
                }
                return(ApiActionResult.Success());
            }
            catch (Exception ex)
            {
                return(ApiActionResult.Failed(ex.Message));

                throw ex;
            }
        }
 public ApiActionResult Create(CommonResourcesCreateModel model)
 {
     try
     {
         CommonResources obj = new CommonResources();
         obj = _mapper.Map <CommonResources>(model);
         _dbConfigContext.CommonResources.Add(obj);
         var flag = _dbConfigContext.SaveChanges();
         if (flag != 0)
         {
             return(ApiActionResult.Success());
         }
         return(ApiActionResult.Failed("Created Failed!!"));
     }
     catch (Exception ex)
     {
         return(ApiActionResult.Failed(ex.Message));
     }
 }
Example #10
0
        public ApiActionResult CreateNewCommonValues(CommonValueCreateModel model)
        {
            try
            {
                CommonValues obj = new CommonValues();
                obj          = _mapper.Map <CommonValueCreateModel, CommonValues>(model);
                obj.UniqueId = UniqueIDHelper.GenerateRandomString(12);
                _dbConfigContext.CommonValues.Add(obj);
                var flag = _dbConfigContext.SaveChanges();

                if (flag != 0)
                {
                    return(ApiActionResult.Success());
                }
                return(ApiActionResult.Failed("Created Failed"));
            }
            catch (Exception ex)
            {
                return(ApiActionResult.Failed(ex.Message));
            }
        }
 public ApiActionResult Delete(CommonResourcesCreateModel model)
 {
     try
     {
         var obj = _dbConfigContext.CommonResources.AsNoTracking().Where(x => x.ResourceKey == model.ResourceKey && x.LanguageFid == model.LanguageFid && x.TypeOfResource == model.TypeOfResource).FirstOrDefault();
         if (obj != null)
         {
             _dbConfigContext.CommonResources.Remove(obj);
             _dbConfigContext.SaveChanges();
             return(ApiActionResult.Success());
         }
         else
         {
             return(ApiActionResult.Failed("Can not find data to delete"));
         }
     }
     catch (Exception ex)
     {
         return(ApiActionResult.Failed(ex.Message));
     }
 }