Esempio n. 1
0
        public JsonResult UpdateEntry(ENT.UserProfile model, string up_id)
        {
            try
            {
                model.UpdatedDateTime = DateTime.Now;
                model.UpdatedBy       = Guid.Parse(User.Identity.GetUserId());
                model.up_id           = new Guid(up_id.Replace("/", ""));
                if (objBAL.UpdatePartial(model))
                {
                    new BAL.MasterDistributor().UpdateSlab(model.slabid, model.up_id);
                    //string id = User.Identity.GetUserId();
                    //  ApplicationUser currentUser = UserManager.FindById(id);
                    var user = new ApplicationUser();
                    user.Email = model.up_email;

                    GlobalVarible.AddMessage("Record Update Successfully");
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public bool UpdatePartialOther(ENT.UserProfile objEntity)
        {
            bool blnResult = false;

            try
            {
                //Create Fields List in dictionary
                Dictionary <string, bool> dctFields = new Dictionary <string, bool>();
                dctFields.Add(COM.HelperMethod.PropertyName <ENT.UserProfile>(x => x.up_id), true);
                dctFields.Add(COM.HelperMethod.PropertyName <ENT.UserProfile>(x => x.up_username), false);
                dctFields.Add(COM.HelperMethod.PropertyName <ENT.UserProfile>(x => x.up_email), false);
                dctFields.Add(COM.HelperMethod.PropertyName <ENT.UserProfile>(x => x.up_address), false);
                dctFields.Add(COM.HelperMethod.PropertyName <ENT.UserProfile>(x => x.UpdatedBy), false);
                dctFields.Add(COM.HelperMethod.PropertyName <ENT.UserProfile>(x => x.UpdatedDateTime), false);
                objEntity.FieldCollection = dctFields;
                if (objDAL.SaveChanges(objEntity.FieldCollection, objEntity))
                {
                    blnResult = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(blnResult);
        }
Esempio n. 3
0
 public JsonResult UpdateStatus(string id)
 {
     GlobalVarible.Clear();
     try
     {
         if (id != null)
         {
             Model       = new Web.Framework.Entity.UserProfile();
             Model.up_id = new Guid(id);
             Model       = (ENT.UserProfile)objBAL.GetByPrimaryKey(Model);
             if (Model.Status == COM.MyEnumration.MyStatus.Active)
             {
                 if (!objBAL.UpdateStatus(Model.up_id, COM.MyEnumration.MyStatus.DeActive))
                 {
                     throw new Exception("Internal Server Error in status update.");
                 }
             }
             if (Model.Status == COM.MyEnumration.MyStatus.DeActive)
             {
                 if (!objBAL.UpdateStatus(Model.up_id, COM.MyEnumration.MyStatus.Active))
                 {
                     throw new Exception("Internal Server Error in status update.");
                 }
             }
             GlobalVarible.AddMessage("Status Update Successfully.");
         }
     }
     catch (Exception ex)
     {
         GlobalVarible.AddError(ex.Message);
     }
     MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
     return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
 }
Esempio n. 4
0
 public JsonResult EditRecord(string id)
 {
     if (id != null)
     {
         Model = new Web.Framework.Entity.UserProfile();
         Model.UpdatedDateTime = DateTime.Now;
         Model.up_id           = new Guid(id);
         Model = (ENT.UserProfile)objBAL.GetByPrimaryKey(Model);
     }
     return(Json(new { Model = Model }, JsonRequestBehavior.AllowGet));
 }
Esempio n. 5
0
    // private constructor
    private MySession()
    {
        Username       = null;
        PasswordChange = null;
        UserFullname   = null;
        MessageResult  = new FormResultEntity();

        UserProfile      = new Web.Framework.Entity.UserProfile();
        ExportVendor     = new GridView();
        ExportCollection = new GridView();
        ExportVoucher    = new GridView();
    }
Esempio n. 6
0
        public object GetByPrimaryKey(ENT.UserProfile Entity)
        {
            object objResult = null;

            try
            {
                DAL.CRUDOperation tt = new DAL.CRUDOperation();
                objResult = tt.GetEntityByPrimartKey(Entity);
            }
            catch (Exception)
            {
                throw;
            }
            return(objResult);
        }
Esempio n. 7
0
        public JsonResult SearchCustomer(string id)
        {
            bool EStatu = true;

            if (id != null)
            {
                Model = new Web.Framework.Entity.UserProfile();
                Model = (ENT.UserProfile)objBAL.SearchData(id);
                if (Model == null)
                {
                    EStatu = false;
                }
            }
            return(Json(new { EntryStatus = EStatu, Model = Model }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 8
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                }
                objDAL    = null;
                clsDAL    = null;
                Entity    = null;
                lstEntity = null;
                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Esempio n. 9
0
 public JsonResult UpdateEntry(ENT.UserProfile model, string up_id)
 {
     try
     {
         model.UpdatedDateTime = DateTime.Now;
         model.UpdatedBy       = Guid.Parse(User.Identity.GetUserId());
         model.up_id           = new Guid(up_id.Replace("/", ""));
         if (objBAL.UpdatePartialOther(model))
         {
             GlobalVarible.AddMessage("Record Update Successfully");
         }
     }
     catch (Exception ex)
     {
         GlobalVarible.AddError(ex.Message);
     }
     MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
     return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
 }
Esempio n. 10
0
        public HttpResponseMessage GetLatesBalance()
        {
            GlobalVarible.Clear();
            try
            {
                using (BAL.UserProfile objBal = new BAL.UserProfile())
                {
                    ENT.UserProfile up = objBal.GetBalance(_LOGINUSERID);

                    GlobalVarible.AddMessage("User Balance Get Successfully.");

                    return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult, up.up_balance }));
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
                ERRORREPORTING.Report(ex, _REQUESTURL, _LOGINUSERID, _ERRORKEY, string.Empty);
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult }));
            }
        }
Esempio n. 11
0
 public JsonResult GetUserProfile()
 {
     Model = new Web.Framework.Entity.UserProfile();
     Model = (ENT.UserProfile)objBAL.GetUserProfile(User.Identity.GetUserId());
     return(Json(new { Model = Model }, JsonRequestBehavior.AllowGet));
 }
Esempio n. 12
0
 public ENT.UserProfile GetSlabName(Guid upperid)
 {
     ENT.UserProfile lstEntity = new ENT.UserProfile();
     lstEntity = clsDAL.GetUserSlabName(upperid);
     return(lstEntity);
 }
Esempio n. 13
0
 public ENT.UserProfile GetBalance(Guid id)
 {
     ENT.UserProfile lstEntity = new ENT.UserProfile();
     lstEntity = clsDAL.GetUserBalance(id);
     return(lstEntity);
 }
Esempio n. 14
0
 public ENT.UserProfile GetUserProfile(string id)
 {
     ENT.UserProfile lstEntity = new ENT.UserProfile();
     lstEntity = clsDAL.GetUserProfile(id);
     return(lstEntity);
 }
Esempio n. 15
0
 public ENT.UserProfile SearchData(string id)
 {
     ENT.UserProfile lstEntity = new ENT.UserProfile();
     lstEntity = clsDAL.SearchCustomerDetails(id);
     return(lstEntity);
 }
        public async Task <JsonResult> RRegister(RegisterViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user = new ApplicationUser {
                        UserName = model.Mobile, Email = model.Email, EmailConfirmed = true, PhoneNumber = model.Mobile
                    };
                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        try
                        {
                            await this.UserManager.AddToRoleAsync(user.Id, "retailer");

                            ENT.UserProfile objmodel = new ENT.UserProfile();
                            BAL.UserProfile objBAL   = new BAL.UserProfile();
                            objmodel                 = new BAL.UserProfile().GetSlabName(Guid.Parse(User.Identity.GetUserId()));
                            objmodel.up_userid       = new Guid(user.Id);
                            objmodel.up_username     = model.UserName;
                            objmodel.up_mobile       = model.Mobile;
                            objmodel.up_email        = model.Email;
                            objmodel.up_address      = model.Address;
                            objmodel.up_upperid      = Guid.Parse(User.Identity.GetUserId());
                            objmodel.up_userlevel    = COM.MyEnumration.Userlevel.R;
                            objmodel.Status          = COM.MyEnumration.MyStatus.Active;
                            objmodel.up_balance      = 0;
                            objmodel.slabid          = objmodel.slabid;
                            objmodel.up_imei         = string.Empty;
                            objmodel.CreatedBy       = Guid.Parse(User.Identity.GetUserId());
                            objmodel.CreatedDateTime = DateTime.Now;

                            if (objBAL.Insert(objmodel))
                            {
                                GlobalVarible.AddMessage("Record Save Successfully");
                            }
                            else
                            {
                                GlobalVarible.AddError("Internal Error...");
                                return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
                            }
                        }
                        catch (Exception ex)
                        {
                            ERRORREPORTING.Report(ex, _REQUESTURL, _LoginUserId, _ERRORKEY, JsonConvert.SerializeObject(model));
                            GlobalVarible.AddError("Contact to developer..");
                            var context = new ApplicationDbContext();
                            await UserManager.DeleteAsync(user);
                        }
                    }
                    else
                    {
                        GlobalVarible.AddErrors(result.Errors.ToList <string>());
                        return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    var           Errors    = ModelState.Select(x => x.Value.Errors).Where(y => y.Count > 0).ToList();
                    List <string> ErrorList = new List <string>();
                    string        error     = string.Empty;
                    foreach (var item in Errors)
                    {
                        error = error + ',' + item[0].ErrorMessage;
                        ErrorList.Add(item[0].ErrorMessage);
                    }
                    ERRORREPORTING.Report(new Exception(error), _REQUESTURL, _LoginUserId, _ERRORKEY, JsonConvert.SerializeObject(model));
                    GlobalVarible.AddErrors(ErrorList);
                    return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 17
0
        public HttpResponseMessage CreateUser(RegisterViewModel model)
        {
            GlobalVarible.Clear();

            try
            {
                var user = new ApplicationUser {
                    UserName = model.Mobile, Email = model.Email, EmailConfirmed = true, PhoneNumber = model.Mobile
                };
                var result = UserManager.Create(user, model.Password);

                if (result.Succeeded)
                {
                    if ((int)User.GetUserlevel() == 1)
                    {
                        this.UserManager.AddToRole(user.Id, "distributor");
                    }
                    else if ((int)User.GetUserlevel() == 2)
                    {
                        this.UserManager.AddToRole(user.Id, "retailer");
                    }

                    using (BAL.UserProfile objBAL = new BAL.UserProfile())
                    {
                        ENT.UserProfile userProfile = objBAL.GetSlabName(_LOGINUSERID);

                        objBAL.Entity.up_userid   = new Guid(user.Id);
                        objBAL.Entity.up_username = model.UserName;
                        objBAL.Entity.up_mobile   = model.Mobile;
                        objBAL.Entity.up_email    = model.Email;
                        objBAL.Entity.up_address  = model.Address;
                        objBAL.Entity.up_upperid  = _LOGINUSERID;

                        if ((int)User.GetUserlevel() == 1)
                        {
                            objBAL.Entity.up_userlevel = COM.MyEnumration.Userlevel.SD;
                        }
                        else if ((int)User.GetUserlevel() == 2)
                        {
                            objBAL.Entity.up_userlevel = COM.MyEnumration.Userlevel.R;
                        }

                        objBAL.Entity.Status          = COM.MyEnumration.MyStatus.Active;
                        objBAL.Entity.up_balance      = 0;
                        objBAL.Entity.slabid          = userProfile.slabid;
                        objBAL.Entity.up_imei         = string.Empty;
                        objBAL.Entity.CreatedBy       = _LOGINUSERID;
                        objBAL.Entity.CreatedDateTime = DateTime.Now;

                        if (objBAL.Insert(objBAL.Entity))
                        {
                            GlobalVarible.AddMessage("User created successfully.");
                            return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult }));
                        }
                        else
                        {
                            GlobalVarible.AddError("Unable to save user detail.Please check data and try again.");
                            return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult }));
                        }
                    }
                }
                else
                {
                    GlobalVarible.AddErrors(result.Errors.ToList <string>());
                    ERRORREPORTING.Report(new Exception(string.Join(",", result.Errors.ToList <string>())), _REQUESTURL, _LOGINUSERID, _ERRORKEY, string.Empty);
                    return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult }));
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
                ERRORREPORTING.Report(ex, _REQUESTURL, _LOGINUSERID, _ERRORKEY, string.Empty);
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult }));
            }
        }
Esempio n. 18
0
        private void createRolesandUsers()
        {
            ApplicationDbContext context = new ApplicationDbContext();

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            // In Startup iam creating first Admin Role and creating a default Admin User
            if (!roleManager.RoleExists("administrator"))
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                role.Name = "administrator";
                roleManager.Create(role);

                //Here we create a Admin super user who will maintain the website

                var user = new ApplicationUser();
                user.UserName    = "******";
                user.Email       = "*****@*****.**";
                user.PhoneNumber = "9999999999";

                string userPWD = "admin@123";
                var    chkUser = UserManager.Create(user, userPWD);

                //Add default User to Role Admin
                if (chkUser.Succeeded)
                {
                    var             result1 = UserManager.AddToRole(user.Id, "administrator");
                    ENT.UserProfile obj     = new ENT.UserProfile();
                    BAL.UserProfile objBAL  = new BAL.UserProfile();
                    obj.up_userid    = new Guid(user.Id);
                    obj.up_username  = "******";
                    obj.up_mobile    = "9999999999";
                    obj.up_email     = "*****@*****.**";
                    obj.up_address   = "rajkot";
                    obj.up_upperid   = Guid.Parse("00000000-0000-0000-0000-000000000000");
                    obj.up_userlevel = COM.MyEnumration.Userlevel.ADMIN;
                    obj.Status       = COM.MyEnumration.MyStatus.Active;
                    obj.up_imei      = string.Empty;
                    objBAL.Insert(obj);
                }
                if (!roleManager.RoleExists("apiuser"))
                {
                    var role1 = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                    role1.Name = "apiuser";
                    roleManager.Create(role1);
                }
                if (!roleManager.RoleExists("masterdistributor"))
                {
                    var role1 = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                    role1.Name = "masterdistributor";
                    roleManager.Create(role1);
                }
                if (!roleManager.RoleExists("distributor"))
                {
                    var role1 = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                    role1.Name = "distributor";
                    roleManager.Create(role1);
                }
                if (!roleManager.RoleExists("retailer"))
                {
                    var role1 = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                    role1.Name = "retailer";
                    roleManager.Create(role1);
                }
                if (!roleManager.RoleExists("staff"))
                {
                    var role1 = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                    role1.Name = "staff";
                    roleManager.Create(role1);
                }
            }
        }