Example #1
0
 public JsonResult EditComment(vmComment input)
 {
     if (!ModelState.IsValid)
     {
         return(Json("faild"));
     }
     try
     {
         using (var _Context = new ApplicationDbContext())
         {
             var _objEntityComment = new RepositoryPattern <PostComment>(_Context);
             var CurrentItem       = _objEntityComment.GetByPredicate(x => x.ID == input.ID);
             if (CurrentItem != null)
             {
                 CurrentItem.Is_Active = input.Is_Active;
                 CurrentItem.FullName  = input.FullName;
                 CurrentItem.Comment   = input.Comment;
                 _objEntityComment.Update(CurrentItem);
                 _objEntityComment.Save();
                 _objEntityComment.Dispose();
             }
         }
     }
     catch (Exception)
     {
         return(Json("OK"));
     }
     return(Json("OK"));
 }
Example #2
0
        public void UpdateCustomer(Customers customer)
        {
            Customers cust = repo.Find(x => x.CustomerID == customer.CustomerID);

            cust.ContactName  = customer.ContactName;
            cust.CompanyName  = customer.CompanyName;
            cust.Address      = customer.Address;
            cust.City         = customer.City;
            cust.ContactTitle = customer.ContactTitle;
            cust.Country      = customer.Country;
            cust.Password     = customer.Password;
            cust.Phone        = customer.Phone;
            cust.PostalCode   = customer.PostalCode;
            cust.Region       = customer.Region;
            repo.Update(cust);
        }
Example #3
0
 public JsonResult ReadComment(int id)
 {
     try
     {
         using (var _Context = new ApplicationDbContext())
         {
             var _objEntityComment = new RepositoryPattern <PostComment>(_Context);
             var CurrentItem       = _objEntityComment.GetByPredicate(x => x.ID == id);
             if (CurrentItem != null)
             {
                 CurrentItem.Is_Read = "1";
                 _objEntityComment.Update(CurrentItem);
                 _objEntityComment.Save();
                 _objEntityComment.Dispose();
             }
         }
     }
     catch (Exception)
     {
         return(Json("OK"));
     }
     return(Json("OK"));
 }
Example #4
0
 public void UpdateCustomer(Customer cust)
 {
     repo.Update(cust);
 }
Example #5
0
        public JsonResult EditPost(vmPublishPost input)
        {
            try
            {
                //delete image of Post To Insert New Image For Post (Update)
                if (input.FlagHaveFile == true)
                {
                    DatabaseOperation objDatabaseOperation = new DatabaseOperation();
                    using (var _Context1 = new ApplicationDbContext())
                    {
                        var objEntityPost = new RepositoryPattern <Post>(_Context1);
                        var CurrentItem   = objEntityPost.GetByPredicate(x => x.ID == input.PostID);
                        if (objDatabaseOperation.DeleteImageOfPost(CurrentItem.ImageID))
                        {
                            //InfoUser AppUser = new InfoUser();
                            var TodayDateShamsi = DateConvertor.DateToNumber(DateConvertor.TodayDate());
                            //var NewNewsCode = HelpOperation.NewsCode(Convert.ToInt32(TodayDateShamsi));
                            HelpOperation.CreateArchiveFolderOnTheServer();
                            HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase;
                            var FileSize           = HelpOperation.ToFileSize(hpf.ContentLength);
                            var GuidID             = CurrentItem.ImageID;
                            var FileNameOnServer   = GuidID + Path.GetExtension(hpf.FileName);
                            var FilePath           = @"~\MediaFiles\Image\" + FileNameOnServer;
                            var FilePathOnServer   = Server.MapPath(FilePath);
                            var FileUrl            = HelpOperation.MapToUrl(FilePath);
                            Request.Files[0].SaveAs(FilePathOnServer);
                            using (var _ContextImage = new ApplicationDbContext())
                            {
                                var _objEntityImage = new RepositoryPattern <Image>(_ContextImage);
                                var NewItemImage    = new Image
                                {
                                    ID               = GuidID,
                                    TitleUrl         = input.Title,
                                    FileName         = FileNameOnServer,
                                    FileSize         = FileSize,
                                    FileUrl          = FileUrl,
                                    FilePathOnServer = FilePath
                                };
                                _objEntityImage.Insert(NewItemImage);
                                _objEntityImage.Save();
                                _objEntityImage.Dispose();
                            }
                        }
                    }
                }

                using (var _context = new ApplicationDbContext())
                {
                    var objEntityPost = new RepositoryPattern <Post>(_context);
                    var CurrentItem   = objEntityPost.GetByPredicate(x => x.ID == input.PostID);

                    CurrentItem.Title      = input.Title.Trim();
                    CurrentItem.CategoryID = input.CategoryID;
                    //Categories = new List<Category>() {  new Category() {ID = CategoryID, } },
                    CurrentItem.Content            = input.Content;
                    CurrentItem.IsActive           = input.IsActive == "true" ? "0" : "1";
                    CurrentItem.Labels             = input.Tagsinput.Trim();
                    CurrentItem.SeoMetaDescription = input.SeoMetaDescription.Trim();
                    //CurrentItem.PostDate = DateConvertor.DateToNumber(DateConvertor.TodayDate());
                    //CurrentItem.PostTime = DateConvertor.TimeNowShort();

                    objEntityPost.Update(CurrentItem);
                    objEntityPost.Save();

                    objEntityPost.Dispose();
                }
                return(Json("OK"));
            }
            catch (Exception)
            {
                return(Json("Faild"));
            }
        }
Example #6
0
        //public void EtkinligeKatil(int organizeid, OrganizeKullanici org)
        //{
        //	if (db.OrganizeKullanicis.Any(x => x.OrganizeID == organizeid)) return;
        //	OrganizeKullanici ok = new OrganizeKullanici();
        //	ok.OrganizeID = org.OrganizeID;
        //	ok.KatilimciID = org.KatilimciID;
        //	ok.KayitTarihi = org.KayitTarihi;
        //	ok.KatılımcıSayisi = org.KatılımcıSayisi;

        //	db.OrganizeKullanicis.Add(ok);
        //	db.SaveChanges();
        //}


        public void OrganizeKullaniciUpdate(OrganizeKullanici organizeKullanici)
        {
            repo1.Update(organizeKullanici);
        }
        public string UpdateTableAndfieldconfiguration(TableAndFieldConfigurationServiceModel tableAndFieldConfiguration)
        {
            try
            {
                if (tableAndFieldConfiguration == null)
                {
                    //return Exception;
                }
                var dataToInsert            = new List <FieldConfiguration>();
                var dataToUpdate            = new List <FieldConfiguration>();
                var idsToDeleteFieldMapping = new List <FieldMappingConfiguration>();

                using (var repo = new RepositoryPattern <TableConfiguration>())
                {
                    var detailsToUpdate = Mapper.Map <TableConfiguration>(tableAndFieldConfiguration.tableConfiguration);
                    repo.Update(detailsToUpdate);
                    repo.Save();
                }
                tableAndFieldConfiguration.fieldConfiguration.ForEach(f =>
                                                                      { f.TableConfigId = tableAndFieldConfiguration.tableConfiguration.Id; f.IsDisplay = true; });

                dataToInsert = Mapper.Map <List <FieldConfiguration> >(tableAndFieldConfiguration.fieldConfiguration.Where(f => f.Id == default(int)).ToList());
                dataToUpdate = Mapper.Map <List <FieldConfiguration> >(tableAndFieldConfiguration.fieldConfiguration.Where(u => u.Id != default(int)).ToList());

                var configurationIds = dataToUpdate.Select(i => i.Id).ToList();

                using (var repo = new RepositoryPattern <FieldConfiguration>())
                {
                    //Update existing records which will not display in future
                    var records = repo.SelectAll().Where(f => f.TableConfigId == tableAndFieldConfiguration.tableConfiguration.Id &&
                                                         !configurationIds.Any(c => c == f.Id)).Select(c => { c.IsDisplay = false; return(c); }).ToList();

                    if (records.Any())
                    {
                        dataToUpdate.AddRange(records);
                    }

                    if (dataToUpdate.Any())
                    {
                        repo.BulkUpdate(dataToUpdate);
                    }
                    if (dataToInsert.Any())
                    {
                        repo.BulkInsert(dataToInsert);
                    }

                    idsToDeleteFieldMapping.AddRange(repo.SelectAll().Where(h => h.TableConfigId == tableAndFieldConfiguration.tableConfiguration.Id && h.FieldMappingConfigurations.Any())
                                                     .SelectMany(g => g.FieldMappingConfigurations).ToList());
                }
                tableAndFieldConfiguration.fieldConfiguration.ForEach(field =>
                {
                    if (field.Id == default(int))
                    {
                        var dataWithIds = dataToInsert.FirstOrDefault(a => a.SourceColumnName == field.SourceColumnName &&
                                                                      a.TableConfigId == field.TableConfigId && a.ReferenceTableName == field.ReferenceTableName &&
                                                                      a.ReferenceColumnName == field.ReferenceColumnName && field.IsDisplay).Id;
                        field.Id = dataWithIds;
                    }
                });

                List <FieldMappingConfiguration> fieldMappingConfigurations = new List <FieldMappingConfiguration>();
                tableAndFieldConfiguration.fieldConfiguration.ForEach(fields =>
                {
                    if (fields.MappedCoumns.Any())
                    {
                        fields.MappedCoumns.ForEach(m =>
                        {
                            var mappingDetails = new FieldMappingConfiguration()
                            {
                                FieldConfigurationId = fields.Id,
                                MapColumnName        = m,
                                MapTableName         = fields.ReferenceTableName,
                            };
                            fieldMappingConfigurations.Add(mappingDetails);
                        });
                    }
                });

                using (var repo = new RepositoryPattern <FieldMappingConfiguration>())
                {
                    if (idsToDeleteFieldMapping.Any())
                    {
                        repo.BulkDelete(idsToDeleteFieldMapping);
                    }
                    if (fieldMappingConfigurations.Any())
                    {
                        repo.BulkInsert(fieldMappingConfigurations);
                    }
                }

                return("Table and field mapping Save succesfully");
            }
            catch (Exception ex)
            {
                throw;
            }
        }