示例#1
0
        public SPResponse ActiveInactiveSourceBy(int Sourcedbyid)
        {
            tblSourcedBy objsource = new tblSourcedBy();
            SPResponse   result    = new SPResponse();

            using (var context = new CommonDBContext())
            {
                objsource = context.tblSourcedBies.Where(x => x.SourcedbyId == Sourcedbyid).FirstOrDefault();

                if (objsource.IsActive == true)
                {
                    objsource.IsActive = false;
                }
                else
                {
                    objsource.IsActive = true;
                }

                context.tblSourcedBies.AddOrUpdate(objsource);
                context.SaveChanges();
                result.ResponseCode    = "00";
                result.ResponseMessage = "SourceBy Updated Successfully";
            }
            return(result);
        }
        public ActionResult AddSource(string jsonData)
        {
            SPResponse result      = new SPResponse();
            var        userDetails = (CustomerLoginDetail)Session["UserSession"];
            string     SourceId    = "";

            try
            {
                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                json_serializer.MaxJsonLength = int.MaxValue;
                object[]     objData   = (object[])json_serializer.DeserializeObject(jsonData);
                tblSourcedBy objsource = new tblSourcedBy();
                foreach (Dictionary <string, object> item in objData)
                {
                    objsource.SourcedbyName = Convert.ToString(item["SourceNm"]);
                    objsource.CreatedBy     = userDetails.LoginId;
                    objsource.CreatedDate   = DateTime.Now;
                    SourceId           = Convert.ToString(item["SourceId"]);
                    objsource.IsActive = Convert.ToBoolean(item["IsActive"]);
                    if (SourceId != "")
                    {
                        objsource.SourcedbyId = Convert.ToInt32(SourceId);
                    }
                    else
                    {
                    }
                }
                result = COR.AddSource(objsource);
            }
            catch (Exception ex)
            {
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public tblSourcedBy GetSourceById(int SourceId)
        {
            tblSourcedBy objsource = new tblSourcedBy();

            using (var context = new CommonDBContext())
            {
                objsource = context.tblSourcedBies.Where(x => x.SourcedbyId == SourceId).FirstOrDefault();
            }
            return(objsource);
        }
        public ActionResult GetSource(int SourceId)
        {
            tblSourcedBy objsource = new tblSourcedBy();

            try
            {
                objsource = COR.GetSourceById(SourceId);
            }
            catch (Exception ex)
            {
            }
            return(Json(objsource, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public SPResponse AddSource(tblSourcedBy objtblSourceBy)
        {
            SPResponse result = new SPResponse();

            try
            {
                using (var context = new CommonDBContext())
                {
                    context.tblSourcedBies.AddOrUpdate(objtblSourceBy);
                    context.SaveChanges();
                    result.ResponseCode    = "00";
                    result.ResponseMessage = "Source Added Successfully";
                }
            }
            catch (Exception ex)
            {
                newexception.AddException(ex, "onboarding_master");
            }
            return(result);
        }
        public int AddGroupDetails(tblGroupDetail objGroupDetails)
        {
            int GroupId = 0;

            using (var context = new CommonDBContext())
            {
                using (DbContextTransaction transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(objGroupDetails.OtherBillingPartner))
                        {
                            tblBillingPartner objBillingPartner = new tblBillingPartner();
                            objBillingPartner.BillingPartnerName = objGroupDetails.OtherBillingPartner;
                            context.tblBillingPartners.AddOrUpdate(objBillingPartner);
                            context.SaveChanges();
                            objGroupDetails.BillingPartner = objBillingPartner.BillingPartnerId;
                        }
                        if (!string.IsNullOrEmpty(objGroupDetails.OtherCity))
                        {
                            tblCity objCity = new tblCity();
                            objCity.CityName = objGroupDetails.OtherCity;
                            context.tblCities.AddOrUpdate(objCity);
                            context.SaveChanges();
                            objGroupDetails.City = objCity.CityId;
                        }
                        if (!string.IsNullOrEmpty(objGroupDetails.OtherRetailCategory))
                        {
                            tblCategory objCategory = new tblCategory();
                            objCategory.CategoryName = objGroupDetails.OtherRetailCategory;
                            context.tblCategories.AddOrUpdate(objCategory);
                            context.SaveChanges();
                            objGroupDetails.RetailCategory = objCategory.CategoryId;
                        }
                        if (!string.IsNullOrEmpty(objGroupDetails.OtherRMAssigned))
                        {
                            tblRMAssigned objRMAssigned = new tblRMAssigned();
                            objRMAssigned.RMAssignedName = objGroupDetails.OtherRMAssigned;
                            context.tblRMAssigneds.AddOrUpdate(objRMAssigned);
                            context.SaveChanges();
                            objGroupDetails.RMAssigned = objRMAssigned.RMAssignedId;
                        }
                        if (!string.IsNullOrEmpty(objGroupDetails.OtherSourcedBy))
                        {
                            tblSourcedBy objSourcedBy = new tblSourcedBy();
                            objSourcedBy.SourcedbyName = objGroupDetails.OtherSourcedBy;
                            context.tblSourcedBies.AddOrUpdate(objSourcedBy);
                            context.SaveChanges();
                            objGroupDetails.SourcedBy = objSourcedBy.SourcedbyId;
                        }

                        if (!string.IsNullOrEmpty(objGroupDetails.Logo))
                        {
                            //Upload Logo Image
                            var          profilePhysicalURL = System.Configuration.ConfigurationManager.AppSettings["LogoPhysicalURL"];
                            string       filePhysicalPath   = System.IO.Path.Combine(profilePhysicalURL + "\\");
                            string       base64String       = Convert.ToString(objGroupDetails.LogoBase64);
                            byte[]       newBytes           = Convert.FromBase64String(base64String);
                            MemoryStream ms = new MemoryStream(newBytes, 0, newBytes.Length);
                            ms.Write(newBytes, 0, newBytes.Length);
                            var        fileName = Convert.ToString(objGroupDetails.GroupId + ".jpg");
                            FileStream fileNew  = new FileStream(filePhysicalPath + "\\" + fileName, FileMode.Create, FileAccess.Write);
                            ms.WriteTo(fileNew);
                            fileNew.Close();
                            ms.Close();
                            objGroupDetails.Logo = fileName;
                        }

                        string grpId = Convert.ToString(objGroupDetails.GroupId);
                        //Check Customer DB exist
                        var DBDetails = context.DatabaseDetails.Where(x => x.GroupId == grpId).FirstOrDefault();
                        if (DBDetails == null)
                        {
                            //Create Customer DB And Add Entry to DatabaseDetails Table
                            var LastGroupId = context.tblGroupDetails.OrderByDescending(x => x.GroupId).Take(1).Select(y => y.GroupId).FirstOrDefault();
                            objGroupDetails.GroupId = LastGroupId + 1;
                        }

                        context.tblGroupDetails.AddOrUpdate(objGroupDetails);
                        context.SaveChanges();

                        transaction.Commit();
                        GroupId = objGroupDetails.GroupId;
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
            }

            return(GroupId);
        }