예제 #1
0
        private ResultDto InsertUpdateBranchMaster(BranchDto branchDto)
        {
            ResultDto resultDto = new ResultDto();
            string    obectName = "branch";

            try
            {
                ObjectParameter prmBranchId   = new ObjectParameter("BranchID", branchDto.BranchID);
                ObjectParameter prmBranchCode = new ObjectParameter("BranchCode", string.Empty);
                int             effectedRow   = _dbContext.uspBranchInsertUpdate(prmBranchId, branchDto.BranchName, branchDto.TEBranchName, branchDto.StartDate, branchDto.Phone,
                                                                                 branchDto.Email, branchDto.Address, branchDto.AccountantID, branchDto.AccountantFromDate, branchDto.ManagerID, branchDto.ManagerFromDate, branchDto.UserID, prmBranchCode);

                resultDto.ObjectId   = (int)prmBranchId.Value;
                resultDto.ObjectCode = string.IsNullOrEmpty((string)prmBranchCode.Value) ? branchDto.BranchCode : (string)prmBranchCode.Value;

                if (resultDto.ObjectId > 0)
                {
                    resultDto.Message = string.Format("{0} details saved successfully with code : {1}", obectName, resultDto.ObjectCode);
                }
                else if (resultDto.ObjectId == -1)
                {
                    resultDto.Message = string.Format("Error occured while generating {0} code", obectName);
                }
                else
                {
                    resultDto.Message = string.Format("Error occured while saving {0} details", obectName);
                }
            }
            catch (Exception)
            {
                resultDto.Message  = string.Format("Service layer error occured while saving the {0} details", obectName);
                resultDto.ObjectId = -98;
            }
            return(resultDto);
        }