Ejemplo n.º 1
0
        public string UpdateStaff(UpdateStaff obj)
        {
            string returnResult = (dynamic)null;

            try
            {
                if (obj != null)
                {
                    if (obj.Staffs != null)
                    {
                        var currentItem = _StaffsRepo.Get(obj.Staffs.Id);
                        currentItem.Id            = obj.Staffs.Id;
                        currentItem.DesignationId = obj.Staffs.DesignationId;
                        currentItem.FirstName     = obj.Staffs.FirstName;
                        currentItem.LastName      = obj.Staffs.LastName;
                        currentItem.Cell          = obj.Staffs.Cell;
                        currentItem.Email         = obj.Staffs.Email;
                        currentItem.Address       = obj.Staffs.Address;
                        currentItem.Education     = obj.Staffs.Education;
                        currentItem.GenderId      = obj.Staffs.GenderId;
                        if (obj.Staffs.fleImage == null)
                        {
                            if (obj.Staffs.IP300X200 != null)
                            {
                                currentItem.IP300X200 = obj.Staffs.IP300X200;
                            }
                            else
                            {
                                //[NOTE: delete image from 'ClientDictionary']
                                string targetImageLocation = Path.Combine(obj.WebRootPath, currentItem.IP300X200);
                                _commonServ.DelFileFromLocation(targetImageLocation);
                            }
                        }
                        else
                        {
                            //[NOTE: delete image from 'ClientDictionary-if extensions are different']
                            if (currentItem.IP300X200 != null)
                            {
                                string targetImageLocation = Path.Combine(obj.WebRootPath, currentItem.IP300X200);
                                _commonServ.DelFileFromLocation(targetImageLocation);
                            }

                            //[NOTE: Upddate image]
                            string imagePathIP300X200 = "ClientDictionary/Staffs/IP300X200/";
                            string extension          = Path.GetExtension(obj.Staffs.fleImage.FileName);
                            if (_commonServ.CommImage_ImageFormat(obj.Staffs.Id.ToString(), obj.Staffs.fleImage, obj.WebRootPath, imagePathIP300X200, 200, 300, extension).Equals(true))
                            {
                                currentItem.IP300X200 = imagePathIP300X200 + obj.Staffs.Id + extension;
                            }
                        }

                        _StaffsRepo.Update(currentItem);
                        returnResult = "Saved";
                    }
                }
            }
            catch (Exception ex)
            {
                returnResult = "ERROR102:FeeTypesServ/UpdateFeeTypes - " + ex.Message;
            }

            return(returnResult);
        }
        public string UpdateStudent(UpdateStudent obj)
        {
            string returnResult = (dynamic)null;

            try
            {
                if (obj != null)
                {
                    var AdmittedYear = DateTime.ParseExact(obj.Students.Year, "yyyy", null);
                    if (obj.Students != null)
                    {
                        var currentItem = _studentsRepo.Get(obj.Students.Id);
                        currentItem.ClassId          = obj.Students.ClassId;
                        currentItem.GenderId         = obj.Students.GenderId;
                        currentItem.RegistrationNo   = obj.Students.RegistrationNo;
                        currentItem.FirstName        = obj.Students.FirstName;
                        currentItem.LastName         = obj.Students.LastName;
                        currentItem.AdmittedYear     = AdmittedYear;
                        currentItem.PresentAddress   = obj.Students.PresentAddress;
                        currentItem.PermanentAddress = obj.Students.PermanentAddress;
                        currentItem.DOB          = obj.Students.DOB;
                        currentItem.IsActive     = obj.Students.IsActive;
                        currentItem.ModifiedBy   = 0;
                        currentItem.ModifiedDate = DateTime.Now;
                        currentItem.FatherName   = obj.Students.FatherName;
                        currentItem.MotherName   = obj.Students.MotherName;
                        if (obj.Students.fleImage == null)
                        {
                            if (obj.Students.IP300X200 != null)
                            {
                                currentItem.IP300X200 = obj.Students.IP300X200;
                            }
                            else
                            {
                                //[NOTE: delete image from 'ClientDictionary']
                                string targetImageLocation = Path.Combine(obj.WebRootPath, currentItem.IP300X200);
                                _commonServ.DelFileFromLocation(targetImageLocation);
                            }
                        }
                        else
                        {
                            //[NOTE: delete image from 'ClientDictionary-if extensions are different']
                            if (currentItem.IP300X200 != null)
                            {
                                string targetImageLocation = Path.Combine(obj.WebRootPath, currentItem.IP300X200);
                                _commonServ.DelFileFromLocation(targetImageLocation);
                            }

                            //[NOTE: Upddate image]
                            string imagePathIP300X200 = "ClientDictionary/Students/IP300X200/";
                            string extension          = Path.GetExtension(obj.Students.fleImage.FileName);
                            if (_commonServ.CommImage_ImageFormat(obj.Students.Id.ToString(), obj.Students.fleImage, obj.WebRootPath, imagePathIP300X200, 200, 300, extension).Equals(true))
                            {
                                currentItem.IP300X200 = imagePathIP300X200 + obj.Students.Id + extension;
                            }
                        }
                        _studentsRepo.Update(currentItem);
                        returnResult = "Saved";
                    }
                    //[NOTE: Student promotion table table]

                    if (obj.StudentPromotions != null)
                    {
                        var promotion       = _StudentPromotionsRepo.GetAll().ToList();
                        var getStuPromotion = (from sp in promotion
                                               where sp.StudentId == obj.Students.Id
                                               select sp).FirstOrDefault();
                        getStuPromotion.ClassId      = obj.Students.ClassId;
                        getStuPromotion.RollNo       = obj.StudentPromotions.RollNo;
                        getStuPromotion.ClassYear    = AdmittedYear;
                        getStuPromotion.IsActive     = obj.Students.IsActive;
                        getStuPromotion.ModifiedBy   = 0;
                        getStuPromotion.ModifiedDate = DateTime.Now;
                        _StudentPromotionsRepo.Update(getStuPromotion);
                        returnResult = "Saved";
                    }
                }
            }
            catch (Exception ex)
            {
                returnResult = "ERROR102:AddressesServ/UpdateAddress - " + ex.Message;
            }
            return(returnResult);
        }