Esempio n. 1
0
        public string AddUpdateBatchMaster(RoleViewModel Model)
        {
            try
            {
                string      status = "";
                BatchMaster role   = null;

                LogActivityViewModel log = new LogActivityViewModel();
                log.EnteredBy      = Model.EnteredBy;
                log.EnteredDate    = DateTime.Now;
                log.ActioName      = "AddUpdateBatchMaster";
                log.ModuleName     = "Control Panel";
                log.ControllerName = "Admin";
                if (Model.Id > 0)
                {
                    role                = _context.BatchMasters.Where(b => b.Id == Model.Id).FirstOrDefault();
                    status              = "Update Successfully!";
                    log.Activity        = "Update";
                    log.ActivityMessage = "'" + Model.Name + "' is updated.";
                }
                if (role == null)
                {
                    role = new BatchMaster();
                }
                role.IsActive    = Model.IsActive;
                role.Name        = Model.Name;
                role.DateOfStart = !string.IsNullOrEmpty(Model.BatchStartDateStr) ? (DateTime.ParseExact(Model.BatchStartDateStr, "dd/MM/yyyy", CultureInfo.InvariantCulture)) : (DateTime?)null;
                role.DateOfEnd   = !string.IsNullOrEmpty(Model.BatchEndDateStr) ? (DateTime.ParseExact(Model.BatchEndDateStr, "dd/MM/yyyy", CultureInfo.InvariantCulture)) : (DateTime?)null;
                if (Model.Id == 0)
                {
                    status              = "Add Successfully!";
                    log.Activity        = "Create";
                    log.ActivityMessage = "'" + Model.Name + "' is added.";
                    _context.BatchMasters.Add(role);
                }
                _context.SaveChanges();
                logActivityService.CreateLogActivity(log);
                return(status);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Esempio n. 2
0
        public bool SaveUserRegistration(LoginViewModel model)
        {
            bool status = false;

            if (model.Id == 0)
            {
                UserLogin login = new UserLogin
                {
                    Fname       = model.Fname,
                    LName       = model.LName,
                    Department  = model.Department,
                    Designation = model.Designation,
                    Email       = model.Email,
                    IsActive    = true,
                    Password    = model.Password,
                    EnteredDate = DateTime.Now,
                    RoleId      = model.RoleId,
                };
                _context.UserLogins.Add(login);
                if (_context.SaveChanges() == 1)
                {
                    status = true;
                    //========= User Activity ===========
                    LogActivityViewModel log = new LogActivityViewModel();
                    log.EnteredBy       = model.EnteredBy;
                    log.EnteredDate     = DateTime.Now;
                    log.ActioName       = "SaveUserRegistration";
                    log.ModuleName      = "Create User";
                    log.ControllerName  = "Login";
                    log.Activity        = "Create User";
                    log.ActivityMessage = "Add new user '" + model.Fname + (string.IsNullOrEmpty(model.LName) ? "'." : (" " + model.LName + "'."));
                    LogActivityService logActivityService = new LogActivityService();
                    logActivityService.CreateLogActivity(log);
                    //====================================
                }
            }
            return(status);
        }