コード例 #1
0
        public RepositoryResponse AddOrEditStarOfMonth(StarOfMonthModel model, string loggedInuserID)
        {
            _nominationRepo = new NominationRepo();
            baseModel       = new RepositoryResponse();
            try
            {
                string nomID = string.Empty;
                //string IPValue = string.Empty;
                Nomination dbNomModel = new Nomination();
                using (objSOMEntities = new SOMEntities())
                {
                    //var config = objSOMEntities.Configurations.Where(r => r.Module == "SOM" && r.Type == "UPDATEIP" && r.IsActive == true).FirstOrDefault();
                    //IPValue = config.Value;
                    var dbModel = objSOMEntities.StarOfTheMonths.Where(r => r.TransID == model.TransID).FirstOrDefault();
                    if (string.IsNullOrEmpty(model.SelectedNominationID))
                    {
                        dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == dbModel.NominationID).FirstOrDefault();
                    }
                    else
                    {
                        dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == model.SelectedNominationID.Replace("\r\n", "")).FirstOrDefault();
                    }


                    if (dbModel == null)
                    {
                        nomID   = dbNomModel.NominationId;
                        dbModel = new StarOfTheMonth.DataBase.StarOfTheMonth();

                        dbModel.EmpId      = int.Parse(dbNomModel.EmployeeNumber);
                        dbModel.IsApproved = true;
                        dbModel.IsDisplay  = true;

                        if (string.IsNullOrEmpty(model.Month))
                        {
                            dbModel.Month = model.MonthFilter;
                        }
                        else
                        {
                            dbModel.Month = model.Month;
                        }
                        if (string.IsNullOrEmpty(model.Year))
                        {
                            dbModel.Year = model.YearFilter;
                        }
                        else
                        {
                            dbModel.Year = model.Year;
                        }

                        dbModel.NominationID = dbNomModel.NominationId;
                        dbModel.Description  = dbNomModel.Idea;
                        dbModel.ApprovedBy   = int.Parse(loggedInuserID);
                        dbModel.CreatedBy    = int.Parse(loggedInuserID);
                        //dbModel.CreatedDate = toISTDate(DateTime.Now);
                        dbModel.ModifiedBy = int.Parse(loggedInuserID);
                        // dbModel.ModifiedDate = toISTDate(DateTime.Now);

                        objSOMEntities.StarOfTheMonths.Add(dbModel);
                        objSOMEntities.SaveChanges();
                        baseModel = new RepositoryResponse {
                            success = true, message = "Star of Month Declared Successfully", Data = ""
                        };
                    }
                    else
                    {
                        nomID = dbModel.NominationID;
                        //dbModel.EmpId = int.Parse(model.EmpId);
                        //dbModel.IsApproved = true;
                        //dbModel.IsDisplay = true;
                        //dbModel.Description = model.Description;
                        dbModel.Month = model.MonthFilter;
                        dbModel.Year  = model.YearFilter;
                        //dbModel.NominationID = model.NominationID;
                        dbModel.CreatedBy = int.Parse(loggedInuserID);
                        //dbModel.CreatedDate = DateTime.UtcNow;
                        dbModel.ModifiedBy = int.Parse(loggedInuserID);
                        //dbModel.ModifiedDate = DateTime.UtcNow;
                        objSOMEntities.SaveChanges();
                        baseModel = new RepositoryResponse {
                            success = true, message = "Star of Month Declared updated Successfully", Data = ""
                        };
                    }

                    if (dbNomModel != null)
                    {
                        dbNomModel.SOMComments      = model.SOMComments;
                        dbNomModel.SOMSubmittedDate = DateTime.Now.ToString("ddMMyyyy");
                        dbNomModel.SOMSignature     = loggedInuserID;
                        dbNomModel.Status           = (int)NominationStatus.TQC_Declare_SOM;
                        dbNomModel.ModifiedBy       = loggedInuserID;
                        objSOMEntities.SaveChanges();
                    }

                    Evaluation    evalDbModel = objSOMEntities.Evaluations.Where(r => r.NominationID == nomID && r.EvaluatorID != "").FirstOrDefault();
                    long          HODId       = _nominationRepo.GetReportingIDByEmpID(dbNomModel.EmployeeNumber);
                    AuditLogModel objAuditLog = new AuditLogModel();
                    objAuditLog.CurrentStatus    = NominationStatus.TQC_Declare_SOM;
                    objAuditLog.EmployeeNumber   = dbNomModel.EmployeeNumber;
                    objAuditLog.IsNewAlert       = true;
                    objAuditLog.IsNotification   = true;
                    objAuditLog.DepartmentHeadID = HODId.ToString();
                    objAuditLog.TQCHeadID        = loggedInuserID;
                    objAuditLog.EvaluatorID      = evalDbModel.EvaluatorID;
                    objAuditLog.NominationID     = nomID;
                    objAuditLog.CreatedBy        = loggedInuserID;
                    _nominationRepo.AddEntryIntoAuditLog(objAuditLog);
                }


                //if (string.IsNullOrEmpty(IPValue) && IPValue == "true")
                //{
                //    AddOrEditStarOfMonth_IntranetPortal(model, loggedInuserID);
                //}
            }
            catch (Exception ex)
            {
                baseModel = new RepositoryResponse {
                    success = false, message = ex.ToString()
                };
            }
            return(baseModel);
        }
コード例 #2
0
        public RepositoryResponse AddOrEditStarOfMonth_IntranetPortal(StarOfMonthModel model, string loggedInuserID)
        {
            _nominationRepo = new NominationRepo();
            baseModel       = new RepositoryResponse();
            try
            {
                string     nomID      = string.Empty;
                Nomination dbNomModel = new Nomination();
                using (objSOMEntities = new SOMEntities())
                    using (objIPEntities = new IntranetPortalEntities())
                    {
                        var dbModel = objIPEntities.StarOfTheMonths.Where(r => r.TransID == model.TransID).FirstOrDefault();
                        if (string.IsNullOrEmpty(model.SelectedNominationID))
                        {
                            dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == dbModel.NominationID).FirstOrDefault();
                        }
                        else
                        {
                            dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == model.SelectedNominationID.Replace("\r\n", "")).FirstOrDefault();
                        }

                        if (dbModel == null)
                        {
                            nomID   = dbNomModel.NominationId;
                            dbModel = new StarOfTheMonth.DataBase.StarOfTheMonth();

                            dbModel.EmpId      = int.Parse(dbNomModel.EmployeeNumber);
                            dbModel.IsApproved = true;
                            dbModel.IsDisplay  = true;

                            if (string.IsNullOrEmpty(model.Month))
                            {
                                dbModel.Month = model.MonthFilter;
                            }
                            else
                            {
                                dbModel.Month = model.Month;
                            }
                            if (string.IsNullOrEmpty(model.Year))
                            {
                                dbModel.Year = model.YearFilter;
                            }
                            else
                            {
                                dbModel.Year = model.Year;
                            }

                            dbModel.NominationID = dbNomModel.NominationId;
                            dbModel.Description  = dbNomModel.Idea;

                            dbModel.CreatedBy  = int.Parse(loggedInuserID);
                            dbModel.ModifiedBy = int.Parse(loggedInuserID);

                            objIPEntities.StarOfTheMonths.Add(dbModel);
                            objIPEntities.SaveChanges();
                            baseModel = new RepositoryResponse {
                                success = true, message = "Star of Month Details Added Successfully", Data = ""
                            };
                        }
                        else
                        {
                            nomID              = dbModel.NominationID;
                            dbModel.Month      = model.MonthFilter;
                            dbModel.Year       = model.YearFilter;
                            dbModel.CreatedBy  = int.Parse(loggedInuserID);
                            dbModel.ModifiedBy = int.Parse(loggedInuserID);
                            objIPEntities.SaveChanges();
                            baseModel = new RepositoryResponse {
                                success = true, message = "Star of Month Details updated Successfully", Data = ""
                            };
                        }
                    }
            }
            catch (Exception ex)
            {
                baseModel = new RepositoryResponse {
                    success = false, message = ex.ToString()
                };
            }
            return(baseModel);
        }