public IHttpActionResult InsertPublishingCompany(PublishingCompanyMaster _publishingCompany) { string status = string.Empty; try { status = _publishingCompanyService.DuplicityCheck(_publishingCompany); if (status == "Y") { if (_publishingCompany.Id == 0) { _publishingCompanyService.InsertPublishingCompany(_publishingCompany); } else { PublishingCompanyMaster objPublishingCompany = _publishingCompanyService.GetPublishingCompanyById(_publishingCompany); objPublishingCompany.CompanyName = _publishingCompany.CompanyName; objPublishingCompany.ContactPerson = _publishingCompany.ContactPerson; objPublishingCompany.Address = _publishingCompany.Address; objPublishingCompany.Email = _publishingCompany.Email; objPublishingCompany.Phone = _publishingCompany.Phone; objPublishingCompany.Mobile = _publishingCompany.Mobile; objPublishingCompany.Website = _publishingCompany.Website; objPublishingCompany.CountryId = _publishingCompany.CountryId; objPublishingCompany.OtherCountry = _publishingCompany.OtherCountry; objPublishingCompany.Stateid = _publishingCompany.Stateid; objPublishingCompany.OtherState = _publishingCompany.OtherState; objPublishingCompany.Cityid = _publishingCompany.Cityid; objPublishingCompany.OtherCity = _publishingCompany.OtherCity; objPublishingCompany.ModifiedBy = _publishingCompany.EnteredBy; objPublishingCompany.ModifiedDate = System.DateTime.Now; _publishingCompanyService.UpdatePublishingCompany(objPublishingCompany); } status = _localizationService.GetResource("Master.API.Success.Message"); } else { status = "Duplicate"; } } catch (ACSException ex) { status = ex.InnerException.Message; } catch (Exception ex) { status = ex.InnerException.Message; } return(Json(status)); }
public IHttpActionResult InsertPublishingCompany(PublishingCompanyMaster _publishingCompany) { string status = string.Empty; try { status = _publishingCompanyService.DuplicityCheck(_publishingCompany); if (status == "Y") { if (_publishingCompany.Id == 0) { IList <ApplicationSetUp> _mobjApplicationSetUpList = _mobjApplicationSetUpRepository.Table.Where(x => x.key == "PublishingCompanyCode" && x.Deactivate == "N").ToList(); var PublishingCompanySuggesation = _mobjApplicationSetUpList.Select(P => new { PublishingCompanyCodeValue = P.keyValue, Id = P.Id }); _publishingCompany.PublishingCompanyCode = "PCM" + PublishingCompanySuggesation.FirstOrDefault().PublishingCompanyCodeValue; _publishingCompany.PublishingCompanyCode = _publishingCompany.PublishingCompanyCode.ToString().ToUpper(); _publishingCompanyService.InsertPublishingCompany(_publishingCompany); ApplicationSetUp mobjApplicationSetUp = new ApplicationSetUp(); mobjApplicationSetUp.Id = PublishingCompanySuggesation.FirstOrDefault().Id; ApplicationSetUp _ApplicationSetUpUpdate = _mobjApplicationSetUpService.GetApplicationSetUpById(mobjApplicationSetUp); _ApplicationSetUpUpdate.Id = PublishingCompanySuggesation.FirstOrDefault().Id; int Value = Int32.Parse(PublishingCompanySuggesation.FirstOrDefault().PublishingCompanyCodeValue) + 1; _ApplicationSetUpUpdate.keyValue = Value.ToString().PadLeft(4, '0'); _ApplicationSetUpUpdate.ModifiedBy = _publishingCompany.EnteredBy; _ApplicationSetUpUpdate.ModifiedDate = DateTime.Now; _mobjApplicationSetUpService.UpdateApplication(_ApplicationSetUpUpdate); } else { PublishingCompanyMaster objPublishingCompany = _publishingCompanyService.GetPublishingCompanyById(_publishingCompany); objPublishingCompany.CompanyName = _publishingCompany.CompanyName; objPublishingCompany.ContactPerson = _publishingCompany.ContactPerson; objPublishingCompany.Address = _publishingCompany.Address; objPublishingCompany.Email = _publishingCompany.Email; objPublishingCompany.Phone = _publishingCompany.Phone; objPublishingCompany.Mobile = _publishingCompany.Mobile; objPublishingCompany.Website = _publishingCompany.Website; objPublishingCompany.CountryId = _publishingCompany.CountryId; objPublishingCompany.OtherCountry = _publishingCompany.OtherCountry; objPublishingCompany.Stateid = _publishingCompany.Stateid; objPublishingCompany.OtherState = _publishingCompany.OtherState; objPublishingCompany.Cityid = _publishingCompany.Cityid; objPublishingCompany.OtherCity = _publishingCompany.OtherCity; objPublishingCompany.Pincode = _publishingCompany.Pincode; objPublishingCompany.ModifiedBy = _publishingCompany.EnteredBy; objPublishingCompany.ModifiedDate = System.DateTime.Now; _publishingCompanyService.UpdatePublishingCompany(objPublishingCompany); } status = _localizationService.GetResource("Master.API.Success.Message"); } else { status = "Duplicate"; } } catch (ACSException ex) { status = ex.InnerException.Message; } catch (Exception ex) { status = ex.InnerException.Message; } return(Json(status)); }