Ejemplo n.º 1
0
        public async Task <IActionResult> SaveComputerInfo(ComputerInfoViewModel model)
        {
            string msg = "error";

            try
            {
                if (!string.IsNullOrEmpty(model.model) ||
                    !string.IsNullOrEmpty(model.serialNo) ||
                    !string.IsNullOrEmpty(model.serviceCode) ||
                    !string.IsNullOrEmpty(Convert.ToString(model.districtId)) ||
                    !string.IsNullOrEmpty(Convert.ToString(model.thanaId)))
                {
                    var user = await _userManager.FindByNameAsync(model.userName);

                    string        gdNumber      = RandomString(6);
                    GDInformation gDInformation = new GDInformation
                    {
                        ApplicationUserId   = user.Id,
                        gdFor               = model.gdFor,
                        gdDate              = DateTime.Now,
                        gdNumber            = gdNumber,
                        gDTypeId            = model.gDTypeId,
                        productTypeId       = model.productTypeId,
                        documentTypeId      = model.documentTypeId == 0 ? null : model.documentTypeId,
                        documentDescription = model.documentDescription,
                        statusId            = 1
                    };


                    int masterId = await lostAndFoundService.SaveGDInformation(gDInformation);

                    if (model.gdFor == "OTHERS")
                    {
                        OtherPersonInformation otherPerson = new OtherPersonInformation
                        {
                            gDInformationId        = masterId,
                            nationalIdentityTypeId = model.nationalIdentityTypeId == 0 ? null : model.nationalIdentityTypeId,
                            identityNo             = model.identityNo,
                            mobileNo = model.mobileNo
                        };
                        int opi = await lostAndFoundService.SaveOtherPersonInformation(otherPerson);
                    }

                    OtherDocumentDetail otherDocumentDetail = new OtherDocumentDetail
                    {
                        gDInformationId = masterId,
                        modelName       = model.model,
                        serialNo        = model.serialNo,
                        productNumber   = model.serviceCode,
                        colorsId        = model.colorId,
                        price           = model.price,
                        currency        = model.currency
                    };

                    IndentifyInfo indentifyInfo = new IndentifyInfo
                    {
                        gDInformationId = masterId,
                        identifySign    = model.identificationMark,
                        colorsId        = model.colorId
                    };

                    SpaceAndTime spaceAndTime = new SpaceAndTime
                    {
                        gDInformationId = masterId,
                        districtId      = model.districtId,
                        thanaId         = model.thanaId,
                        village         = model.village,
                        placeDetails    = model.addressDetails,
                        lafDate         = model.date,
                        lafTime         = model.time
                    };

                    await otherDocumentService.SaveOtherDocumentDetail(otherDocumentDetail);

                    await lostAndFoundService.SaveIndentifyInfo(indentifyInfo);

                    await lostAndFoundService.SaveSpaceAndTime(spaceAndTime);

                    msg = gdNumber;
                }
                return(Ok(msg));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        //[AllowAnonymous]
        public async Task <IActionResult> SaveGDManInformation([FromBody] GDManInformationViewModel model)
        {
            //return Ok("Success");
            try
            {
                var user = await _userManager.FindByNameAsync(model.userName);

                string        gdNumber      = RandomString(6);
                GDInformation gDInformation = new GDInformation
                {
                    ApplicationUserId   = user.Id,
                    gdFor               = model.gdFor,
                    gdDate              = DateTime.Now,
                    gdNumber            = gdNumber,
                    gDTypeId            = model.gDTypeId,
                    productTypeId       = model.productTypeId,
                    documentTypeId      = model.documentTypeId == 0 ? null : model.documentTypeId,
                    documentDescription = model.documentDescription,
                    statusId            = 1
                };

                int gdId = await lostAndFoundService.SaveGDInformation(gDInformation);


                ManInformation manInformation = new ManInformation
                {
                    gDInformationId        = gdId,
                    relationTypeId         = model.relationTypeId,
                    name                   = model.name,
                    aproxAge               = model.aproxAge,
                    agePeriodId            = model.agePeriodId,
                    genderId               = model.genderId,
                    isHealthDisabled       = model.isHealthDisabled,
                    fatherName             = model.fatherName,
                    motherName             = model.motherName,
                    spouseName             = model.spouseName,
                    nationalIdentityTypeId = model.manNationalIdentityTypeId,
                    identityNo             = model.identityNo,
                    numberTypeId           = model.numberTypeId,
                    number                 = model.number
                };

                int manid = await lostAndFoundService.SaveManInformation(manInformation);

                if (model.gdFor == "OTHERS")
                {
                    OtherPersonInformation otherPerson = new OtherPersonInformation
                    {
                        gDInformationId        = gdId,
                        nationalIdentityTypeId = model.nationalIdentityTypeId == 0 ? null : model.nationalIdentityTypeId,
                        identityNo             = model.identityNo,
                        mobileNo = model.mobileNo
                    };
                    int opi = await lostAndFoundService.SaveOtherPersonInformation(otherPerson);
                }

                IndentifyInfo indentifyInfo = new IndentifyInfo
                {
                    gDInformationId           = gdId,
                    colorsId                  = model.colorsId,
                    identifySign              = model.identifySign,
                    descriptionCircumcisionId = model.descriptionCircumcisionId,
                    religionId                = model.religionId,
                    bloodGroup                = model.bloodGroup,
                    occupationId              = model.occupationId,
                    maritalStatusId           = model.maritalStatusId
                };
                int identityid = await lostAndFoundService.SaveIndentifyInfo(indentifyInfo);

                AddressInformation addressInformation = new AddressInformation
                {
                    districtId     = model.manDistrictId,
                    thanaId        = model.thanaId,
                    houseVillage   = model.postOffice,
                    addressDetails = model.addressDetails,
                    type           = model.addressType,
                    oneLineAddress = model.oneLineAddress,
                };
                int addressId = await addressInformationService.SaveAddressInformation(addressInformation);

                PhysicalDescription physical = new PhysicalDescription
                {
                    manInformationId                   = manid,
                    eyeTypeId                          = model.eyeTypeId,
                    noseTypeId                         = model.noseTypeId,
                    hairTypeId                         = model.hairTypeId,
                    foreHeadTypeId                     = model.foreHeadTypeId,
                    beardTypeId                        = model.beardTypeId,
                    weight                             = model.weight,
                    bodyStructureId                    = model.bodyStructureId,
                    faceShapeTypeId                    = model.faceShapeTypeId,
                    bodyChinTypeId                     = model.bodyChinTypeId,
                    bodyColorId                        = model.bodyColorId,
                    moustacheTypeId                    = model.moustacheTypeId,
                    earTypeId                          = model.earTypeId,
                    neckTypeId                         = model.neckTypeId,
                    heightFeet                         = model.heightFeet,
                    heightInch                         = model.heightInch,
                    specialBirthMarkTypeId             = model.specialBirthMarkTypeId,
                    specialBirthMarkBodyPartId         = model.specialBirthMarkBodyPartId,
                    specialBirthMarkBodyPartPositionId = model.specialBirthMarkBodyPartPositionId,
                    visibleTatto                       = model.visibleTatto,
                    otherIdentityfyMark                = model.otherIdentityfyMark,
                    teethTypeId                        = model.teethTypeId,
                    specialBodyConditionId             = model.specialBodyConditionId,
                };
                int phyId = await lostAndFoundService.SavePhysicalDescription(physical);

                DressDescription dress = new DressDescription
                {
                    manInformationId   = manid,
                    inTheHeadId        = model.inTheHeadId,
                    inTheHeadColorId   = model.inTheHeadColorId,
                    inTheBodyId        = model.inTheBodyId,
                    inTheBodyColorId   = model.inTheBodyColorId,
                    inTheThroatId      = model.inTheThroatId,
                    inTheThroatColorId = model.inTheThroatColorId,
                    inTheWaistId       = model.inTheWaistId,
                    inTheWaistColorId  = model.inTheWaistColorId,
                    inTheLegsId        = model.inTheLegsId,
                    inTheLegsColorId   = model.inTheLegsColorId,
                    inTheEyeId         = model.inTheEyeId,
                    inTheEyeColorId    = model.inTheEyeColorId,
                    shoesSize          = model.shoesSize,
                    shoesSizeType      = model.shoesSizeType,
                };
                int dressId = await lostAndFoundService.SaveDressDescription(dress);

                SpaceAndTime spaceAndTime = new SpaceAndTime
                {
                    gDInformationId = gdId,
                    placeDetails    = model.placeDetails,
                    lafDate         = model.lafDate,
                    lafTime         = model.lafTime,
                    postOfficeId    = model.postOfficeId,
                    thanaId         = model.thanaId,
                    districtId      = model.districtId,
                    divisionId      = model.divisionId
                };
                int sdid = await lostAndFoundService.SaveSpaceAndTime(spaceAndTime);


                if (model.dNAProfileViewModels != null)
                {
                    List <DNAProfileDetails> lstDNAProfile = new List <DNAProfileDetails>();
                    foreach (var item in model.dNAProfileViewModels)
                    {
                        DNAProfileDetails dNAProfileDetails = new DNAProfileDetails
                        {
                            manInformationId = manid,
                            locous           = item.locous,
                            genotype1        = item.genotype1,
                            genotype2        = item.genotype2
                        };
                        lstDNAProfile.Add(dNAProfileDetails);
                    }

                    int dnaId = await lostAndFoundService.SaveDNAProfileDetails(lstDNAProfile);
                }

                return(Ok(gdNumber));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }