Example #1
0
        public bool AddCustomerLogin(string Jsondata)
        {
            bool status      = false;
            var  userDetails = (CustomerLoginDetail)Session["UserSession"];

            // Jsondata.GroupId = userDetails.GroupId;
            // status = DR.AddDashboardCustomerLogin(objcustomerlogin);
            try
            {
                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                json_serializer.MaxJsonLength = int.MaxValue;
                object[] objData = (object[])json_serializer.DeserializeObject(Jsondata);
                DashboardCustomerLogin objcustomerlogin = new DashboardCustomerLogin();
                foreach (Dictionary <string, object> item in objData)
                {
                    objcustomerlogin.MobileNo        = Convert.ToString(item["Customermobileno"]);
                    objcustomerlogin.OutletOrBrandId = Convert.ToString(item["outletid"]);
                    objcustomerlogin.LoginType       = Convert.ToString(item["Logintype"]);
                    objcustomerlogin.GroupId         = userDetails.GroupId;
                    objcustomerlogin.CustomerName    = userDetails.CustomerName;
                }
                status = DR.AddDashboardCustomerLogin(objcustomerlogin);
            }
            catch (Exception ex)
            {
            }
            return(status);
        }
        public bool AddDashboardCustomerLogin(DashboardCustomerLogin objdashboardlogin)
        {
            bool status = false;
            CustomerLoginDetail objdashboardlogindeatils = new CustomerLoginDetail();

            try
            {
                using (var context = new CommonDBContext())
                {
                    CustomerLoginDetail objcustexist = new CustomerLoginDetail();
                    objdashboardlogindeatils = context.CustomerLoginDetails.Where(x => x.LoginId == objdashboardlogin.MobileNo && x.GroupId == objdashboardlogin.GroupId).FirstOrDefault();
                    if (objdashboardlogindeatils == null)
                    {
                        objcustexist.UserId   = objdashboardlogin.GroupId;
                        objcustexist.LoginId  = objdashboardlogin.MobileNo;
                        objcustexist.Password = "******";
                        objcustexist.UserName = objdashboardlogin.CustomerName;
                        if (objdashboardlogin.LoginType == "02")
                        {
                            objcustexist.LevelIndicator = "02";
                            objcustexist.CreatedDate    = DateTime.UtcNow.Date;
                            objcustexist.LoginStatus    = true;
                            objcustexist.UserStatus     = true;
                        }
                        else
                        {
                            objcustexist.LevelIndicator  = "04";
                            objcustexist.CreatedDate     = DateTime.UtcNow.Date;
                            objcustexist.LoginStatus     = true;
                            objcustexist.UserStatus      = true;
                            objcustexist.OutletOrBrandId = objdashboardlogin.OutletOrBrandId;
                        }
                        objcustexist.GroupId   = objdashboardlogin.GroupId;
                        objcustexist.EmailId   = null;
                        objcustexist.MobileNo  = null;
                        objcustexist.LoginType = null;

                        context.CustomerLoginDetails.AddOrUpdate(objcustexist);
                        context.SaveChanges();

                        status = true;
                    }
                    else
                    {
                        status = false;
                    }
                }
            }
            catch (Exception ex)
            {
                newexception.AddException(ex, objdashboardlogin.GroupId);
            }

            return(status);
        }